import { log, resources, SpriteFrame } from "cc";
import Singleton from "../Base/Singleton";
import { ITile } from "../Levels";


export default class ResourceManager extends Singleton {

    static get Instance() {
        return super.GetInstance<ResourceManager>();
    }

    loadDir(path:string, type: typeof SpriteFrame = SpriteFrame) {
        return new Promise<SpriteFrame[]>((resolve, reject) => {
            resources.loadDir(path, SpriteFrame, (err, assets) => {
                if (err) {
                    log('资源加载失败', err);
                    reject(err);
                    return
                }
                // console.log('资源加载成功，数量：', assets.length);
                resolve(assets);
            });
        });
    }

}
